package com.koylu.faces.security.user;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

public class UserImpl implements User{

	private String id;
	private String password;
	private String firstname;
	private String lastname;
	private String email;
	private List   groups;
	private Map    attributes;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getPassword() {
		return password;
	}
	public void setPassword(String password) {
		this.password = password;
	}
	public String getFirstname() {
		return firstname;
	}
	public void setFirstname(String firstname) {
		this.firstname = firstname;
	}
	public String getLastname() {
		return lastname;
	}
	public void setLastname(String lastname) {
		this.lastname = lastname;
	}
	public String getEmail() {
		return email;
	}
	public void setEmail(String email) {
		this.email = email;
	}
	public List getGroups() {
		return groups;
	}
	public void setGroups(List groups) {
		this.groups = groups;
	}
	public void addGroup(Group group){
		if(groups == null){
			groups = new ArrayList();
		}
		groups.add(group);
	}
	public Map getAttributes() {
		return attributes;
	}
	public void setAttributes(Map attributes) {
		this.attributes = attributes;
	}
	public void addAttribute(String attribute, Object value){
		if(attributes == null){
			attributes = new HashMap();
		}
		attributes.put(attribute, value);
	}
	public Object getAttribute(String attribute){
		return attributes == null? null : attributes.get(attribute);
	}
	public String toString() {		
		return ToStringBuilder.reflectionToString(this,ToStringStyle.MULTI_LINE_STYLE);
	}	
}
